﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;
using Maticsoft.BLL;
using Maticsoft.Model;

namespace FineUI.Examples
{
    public partial class admin_addcourse : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] == null)
            {
                Response.Redirect("~/login.aspx");
            }
        }

        protected void btnAddCourse_Click(object sender, EventArgs e)
        {
            if (tbxCourseCredit.Text==""||tbxCourseId.Text==""||tbxCourseName.Text=="")
            {
                Alert.ShowInTop("请输入完整的信息!");
                return;
            }



            string currentId = tbxCourseId.Text.ToString();         
            string currentName = tbxCourseName.Text.ToString();
            string  currentCredit=tbxCourseCredit.Text.ToString();
           



            Maticsoft.BLL.Course Course = new Maticsoft.BLL.Course();
            Maticsoft.Model.Course CourseInfom = new Maticsoft.Model.Course();

            CourseInfom.C_Id = currentId;
            CourseInfom.C_Credit = currentCredit;
            CourseInfom.C_Name = currentName;


            if (Course.Exists(currentId))
            {
                Alert.ShowInTop("该课程编号已存在");
                return;
            
            }

       
            if (Course.Add(CourseInfom))
            {
                Alert.ShowInTop("课程增加成功");
                
            }
            else
            {
                Alert.ShowInTop("课程增加失败");
            }




        }
    }
}